#
# Copyright 2009, Jeffrey Palm.
#

require 'util'

# Instances of 'Track' differ slightly from Info instances, in that
# these represent a digital artifact sitting somewhere, that never
# changes.  Info can change, because the time can change.  Obviously
# both are completely immutable, but two Info's could basically be
# equal even if they had different times.  So a Track differs from
# other Tracks only in where it is located.  Info differ based on
# who owns them, and they mutate based on time.
#
# Created from a library XML. 
#
class Track

  attr_reader :name, :artist, :album, :track_id

  def initialize(name,artist,album,track_id)
    @name         = name
    @artist       = artist
    @album        = album
    @track_id     = track_id
    @simple_track = nil
  end
  
  # Returns a simple form of this track.  This is created lazily
  def simple_track
    if not @simple_track
      @simple_track = Track.new(remove_nasty_stuff(@name), 
                                remove_nasty_stuff(@artist), 
                                remove_nasty_stuff(@album), track_id)
    end
    return @simple_track
  end
  
end
